﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GoogleChartSharp;

namespace HBAClient
{
    public partial class Graph : Form
    {
        private static Dictionary<float, string> _dcPoints = null;
        private static string _strChartName = "Chart";
        public Graph(ref Dictionary<float, string> dcValuesParam)
        {
            InitializeComponent();
            _dcPoints = new Dictionary<float, string>();
            _dcPoints = dcValuesParam;
            //_dcPoints[2] = "";
            //_dcPoints[10] = "";
            //_dcPoints[8] = "";
            //_dcPoints[6] = "";
            //_dcPoints[3] = "";

        }
        public void GoWeb()
        {
            this.pbChartBox.ImageLocation = SimpleGrid();     
        }

        private void btnChartRefresh_Click(object sender, EventArgs e)
        {
            GoWeb();
        }

        public static string SimpleGrid()
        {
                // Instantiate the chart object
            LineChart lineChart = new LineChart(350, 250);

                // Values to be charted
            float[] line1 = new float[_dcPoints.Count()];// { 5, 10, 50, 34, 10, 25 };

                int lineIndx = 0;
                float fCurrVal = 0;
                foreach (float nCurrValue in _dcPoints.Keys)
                {
                    fCurrVal = nCurrValue;
                    while (fCurrVal >= 100)
                    {
                        fCurrVal = nCurrValue / 100;
                    }
                    line1[lineIndx] = fCurrVal;//nCurrValue;
                    lineIndx++;
                    _strChartName = _dcPoints[nCurrValue];
                }

                //for (int i = 0; i < _dcPoints.Count(); i++)
                //{
                //    line1[i]
                //}

                // Set chart title using default color and font
                lineChart.SetTitle("Analizer chart for " + _strChartName);

                // Set the title text, title color and title font size in pixels
                //lineChart.SetTitle("Decimal Dataset Per Line", "0000FF", 14);

                // This is a x and y axis chart. Create two new axis objects
                lineChart.AddAxis(new ChartAxis(ChartAxisType.Left));
                lineChart.AddAxis(new ChartAxis(ChartAxisType.Bottom));
                //string[] labes = new string[] { "10","20","30","4","5","6","7","8","9","100","110","120","130","140"};
                //lineChart.AddAxis(new ChartAxis(ChartAxisType.Left));
                //lineChart.AddAxis(new ChartAxis(ChartAxisType.Bottom, labes));


                // Load the chart with the dataset (line int array)
                lineChart.SetData(line1);

                // Add a grid to the chart (dotted grid lines)
                lineChart.SetGrid(10, 10);
             // retuns the FQDN of the chart
             return lineChart.GetUrl();
        }

        #region WorkingSimpleGraphs
        //public static string SimpleGrid()
        //{
        //    // Instantiate the chart object
        //    LineChart lineChart = new LineChart(250, 150);

        //    // Values to be charted
        //    int[] line1 = new int[] { 5, 10, 50, 34, 10, 25 };

        //    // Set chart title using default color and font
        //    lineChart.SetTitle("Analize chart");

        //    // This is a x and y axis chart. Create two new axis objects
        //    lineChart.AddAxis(new ChartAxis(ChartAxisType.Left));
        //    lineChart.AddAxis(new ChartAxis(ChartAxisType.Bottom));

        //    // Load the chart with the dataset (line int array)
        //    lineChart.SetData(line1);

        //    // Add a grid to the chart (dotted grid lines)
        //    lineChart.SetGrid(10, 10);
        //    // retuns the FQDN of the chart
        //    return lineChart.GetUrl();
        //}
        #endregion
    }
}
